home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / misc / BoulderEngine.lha / BOULDER_feb_12.lha / BOULDER0.C < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-01  |  13.3 KB  |  455 lines

  1. /*
  2. =========================================================
  3. == TO COMPILE : CC FILE.C +L -S                        ==
  4. == TO LINK    : LN FILE.O +LC32  (It's not main body)  ==
  5. ==                                                     ==
  6. == ©1993 by Savel soft inc.                            ==
  7. ==                                                     ==
  8. ==                                                     ==
  9. == Rockford & Boulder Dash is © by First Star soft.    ==
  10. ========Cia BOULDER-DASH Grafinis modulis================
  11. */
  12. #include "INCLUDE:stdio.h"
  13. #include "INCLUDE:exec/types.h"
  14. #include "INCLUDE:devices/audio.h"
  15. #include "INCLUDE:graphics/gfx.h"
  16. #include "INCLUDE:graphics/copper.h"
  17. #include "INCLUDE:graphics/view.h"
  18. #include "INCLUDE:graphics/rastport.h"
  19. #include "INCLUDE:graphics/gels.h"
  20. #include "INCLUDE:graphics/regions.h"
  21. #include "INCLUDE:graphics/clip.h"
  22. #include "INCLUDE:graphics/sprite.h"
  23. #include "INCLUDE:exec/exec.h"
  24. #include "INCLUDE:graphics/text.h"
  25. #include "INCLUDE:graphics/gfxbase.h"
  26. #include "INCLUDE:graphics/gfxmacros.h"
  27. #include "INCLUDE:hardware/dmabits.h"
  28. #include "INCLUDE:hardware/custom.h"
  29. #include "INCLUDE:exec/memory.h"
  30. #include "INCLUDE:intuition/intuition.h"
  31. #define e(x,y) ek[y*30+x]
  32. #define k(x,y) kk[y*30+x]
  33.  
  34. #define DEPTH 3L
  35. #define WIDTH 800L
  36. #define HEIGHT 256L
  37. #define VPWIDTH 640L
  38. #define VPHEIGHT 256L
  39.  
  40. #define NOT_ENOUGH_MEMORY -1000
  41. STATIC UBYTE ek[430];
  42. STATIC UBYTE kk[430];
  43. STATIC UBYTE Adzin,Abum;
  44. SHORT galima();
  45. LONG hsefektai();
  46. STATIC SHORT nereikia,TIM,CRISTAL,HMAGMA;
  47. /* ------ cia prasideda displejus ----- */
  48. struct View view;
  49. struct ViewPort viewport;
  50. struct ColorMap *cm;
  51. struct RasInfo rasinfo;
  52. struct BitMap bitmap;
  53. struct RastPort rastport;
  54. extern struct ColorMap *GetColorMap();
  55. struct GfxBase *GfxBase;
  56. struct View *oldview;
  57. USHORT colortable[]={
  58. 0x000,0xfff,0x44e,0x0c1,
  59. 0x999,0x445,0x999,0xd10,
  60. 0x356,0x55f,0x888,0xc57,
  61. 0x115,0x023,0xf00,0x209,
  62. 0x127,0x213,0x209,0x15f,
  63. 0x190,0x088,0x090,0xf22,
  64. 0x333,0x444,0x555,0x666,
  65. 0x777,0x888,0x999,0xaaa,
  66. 0 };
  67. UWORD *colorpalette;
  68.  
  69. pasiruosk()
  70. {
  71. LONG i,n;
  72. UBYTE *displaymem;
  73.  GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L);
  74.  if (GfxBase==NULL) exit(100);
  75.  
  76.  oldview=GfxBase->ActiView;
  77.  
  78.  InitView(&view);
  79.  InitVPort(&viewport);
  80.  view.ViewPort = &viewport;
  81.  view.Modes =HIRES;
  82.  InitBitMap(&bitmap,DEPTH,WIDTH,HEIGHT);
  83.  InitRastPort(&rastport);
  84.  rastport.BitMap = &bitmap;
  85.  rasinfo.BitMap = &bitmap;
  86.  rasinfo.RxOffset = 20;      /* Kad nesimatytu pvz. */
  87.  rasinfo.RyOffset = 0;
  88.  rasinfo.Next = NULL;
  89.  
  90.  viewport.DWidth = VPWIDTH;
  91.  viewport.DHeight = VPHEIGHT;
  92.  viewport.RasInfo = &rasinfo;
  93.  viewport.DyOffset = 0;
  94.  viewport.DxOffset = 0;
  95.  viewport.Modes =HIRES; /* DUALPF , PFBA , HIRES , LACE , HAM ,SPRITES*/
  96.  cm = GetColorMap(32L);
  97.  if (cm == NULL) { exit(100); }
  98.  colorpalette = (UWORD *)cm->ColorTable;
  99.  for(i=0;i<32;i++) { *colorpalette++ = colortable[i]; }
  100.  viewport.ColorMap = cm;
  101.  for(i=0; i<DEPTH;i++) {
  102.   bitmap.Planes[i] = (PLANEPTR) AllocRaster(WIDTH,HEIGHT);
  103.   }
  104.   MakeVPort(&view,&viewport);
  105.   MrgCop(&view);
  106.   LoadView(&view);
  107.   }
  108. PrntI(x,y,n)
  109. SHORT x,y,n;
  110. {
  111. ClipBlit(&rastport,(long)42,(long)n*10L,&rastport,x,y,(long)10,(long)10,(long)0xC0);
  112. }
  113. Prnt(x,y,n)
  114. USHORT x,y,n;
  115. {
  116. USHORT a;
  117. if(n>999){ return; }
  118. a=n/100; PrntI(x,y,a); n-=a*100; a=n/10; PrntI(x+10,y,a);
  119. n-=a*10; PrntI(x+20,y,n);
  120. }
  121. PrntL(x,y,n)
  122. USHORT x,y;
  123. ULONG n;
  124. {
  125. ULONG a;
  126. a=n/1000; Prnt(x,y,a); n-=a*1000; Prnt(x+30,y,n);
  127. }
  128. hide()
  129. {
  130. LONG x,y,n,i=0;
  131. Audiodzin();
  132. for(n=0;n<7;n++)
  133. { for(x=0;x<30;x++)
  134. { for(y=0;y<13;y++)
  135. { if(galima(47) && e(x,y)!=7) { e(x,y)=7;
  136. ClipBlit(&rastport,(long)0,(long)140,&rastport,(long)x*20L+63L,(long)y*19,(long)20,(long)19,(long)0xC0); }
  137. i=hsefektai(i);
  138. } } }
  139. for(x=0;x<30;x++) { for(y=0;y<13;y++) {
  140. if(e(x,y)!=7) { set(x,y,7);
  141. i=hsefektai(i);
  142.  } } } Audiopip(0);
  143. }
  144. LONG hsefektai(i)
  145. LONG i;
  146. {
  147.  Audiodzin2(i);
  148.  i++;
  149.  if(i==30) {i=0;}
  150.  return(i);
  151. }
  152. show()
  153. {
  154. LONG x,y,n,xx,yy,zz,i=0;
  155.    for(y=0; y<13; y++)
  156.     {
  157.      for(x=0; x<30; x++)
  158.       { ClipBlit(&rastport,(long)0,(long)140,&rastport,(long)x*20L+63L,(long)y*19,(long)20,(long)19,(long)0xC0); }
  159.      }
  160. for(xx=0;xx<390;xx++) {kk[xx]=11; }
  161. Audiodzin();
  162. for(xx=0;xx<6;xx++)
  163. {
  164.  for(x=0;x<30;x++)
  165.  {
  166.   for(y=0;y<13;y++)
  167.   {
  168.    if(k(x,y)>10)
  169.     {
  170.      if(galima((short)53)) {
  171.           i=hsefektai(i);
  172.          set(x,y,e(x,y)); if(e(x,y)==9)
  173.        { set(x,y,7); e(x,y)=9; }
  174.        }
  175.     }
  176.   }
  177.  }
  178. }
  179. for(x=0;x<30;x++)
  180. {
  181.  for(y=0;y<13;y++)
  182.  {
  183.   if(k(x,y)>10) { 
  184.      i=hsefektai(i);
  185.      set(x,y,e(x,y)); if(e(x,y)==9)
  186.     { set(x,y,7); e(x,y)=9; }
  187.    }
  188.  }
  189. } Audiopip(0);
  190. } /* END of SHOW */
  191.  
  192. set(x,y,n)
  193. LONG x,y,n;
  194. {
  195. LONG xx;
  196.  k(x,y)=0;
  197.  e(x,y)=n;
  198.  if(n>14) {
  199.            if(n==15){n=8;}
  200.            if(n==16){n=6;}
  201.            if(n==17){n=11;}
  202.            if(n==20){n=10;}
  203.           }
  204.  xx=63L+x*20L;
  205. if(n<12)
  206.  ClipBlit(&rastport,(long)0,(long)n*20,&rastport,(long)xx,(long)y*19,(long)20,(long)19,(long)0xc0);
  207. else
  208.  {
  209. ClipBlit(&rastport,(long)21,(long)20L*(n-12),&rastport,(long)xx,(long)y*19,(long)20,(long)19,(long)0xc0);}
  210.   }
  211. /* END of SET */
  212. Makegraphics()
  213. {
  214. LONG n,a,b;
  215.  
  216. SetAPen(&rastport,4L); RectFill(&rastport,0L,100L,20L,103L);
  217. RectFill(&rastport,0L,115L,20L,119L);
  218. SetAPen(&rastport,3L); RectFill(&rastport,0L,104L,20L,107L);
  219. RectFill(&rastport,0L,112L,20L,114L);
  220. SetAPen(&rastport,2L); RectFill(&rastport,0L,108L,20L,111L);
  221. SetAPen(&rastport,0L);
  222. for(n=0;n<20;n++) {Move(&rastport,n,99L); Draw(&rastport,20L-n,120L); }
  223.                              /* Supaprastintas drugelis */
  224.  
  225. SetAPen(&rastport,1L); RectFill(&rastport,21L,20L,41L,39L);
  226. SetAPen(&rastport,0L); plot(21,26); Draw(&rastport,42L,26L);
  227. plot(21,32); Draw(&rastport,42L,32L);
  228. plot(21,39); Draw(&rastport,42L,39L);
  229. /* judancios sienos variantas */
  230.  
  231.  
  232. SetAPen(&rastport,5L);
  233. for(n=8;n>0;n--) { DrawEllipse(&rastport,30L,49L,n,n); }
  234. SetAPen(&rastport,6L);
  235. DrawEllipse(&rastport,30L,49L,9L,8L);
  236. plot(30,43); plot(30,44); plot(33,46); plot(36,48);
  237. SetAPen(&rastport,7L); plot(29,57); plot(30,56);
  238. plot(32,56); plot(34,55);
  239. /* BOMBA */
  240.  
  241. SetAPen(&rastport,1L); RectFill(&rastport,22L,121L,41L,130L);
  242. SetAPen(&rastport,6L); plot(26,132); plot(27,133);
  243. plot(28,134); plot(29,135); /* Akmenu generat. */
  244.  
  245. SetAPen(&rastport,2L); RectFill(&rastport,28L,145L,35L,157L);
  246. SetAPen(&rastport,1L); RectFill(&rastport,22L,141L,41L,150L);
  247. SetAPen(&rastport,0L); plot(22,145); Draw(&rastport,141L,145L);
  248. /* Bril. generatorius */
  249.  
  250. SetAPen(&rastport,7L); RectFill(&rastport,22L,193L,41L,199L);
  251. SetAPen(&rastport,1L); RectFill(&rastport,23L,194L,40L,198L);
  252. SetAPen(&rastport,3L); RectFill(&rastport,28L,189L,35L,192L);
  253. /* Mina */
  254.  
  255. SetAPen(&rastport,1L); RectFill(&rastport,31L,226L,32L,236L);
  256. RectFill(&rastport,25L,230L,35L,231L); SetAPen(&rastport,2L);
  257. plot(31,230); plot(32,231); SetAPen(&rastport,4L);
  258. plot(32,230); plot(31,231); /* Juod. skyle. */
  259.  
  260. SetAPen(&rastport,6L);
  261. for(n=8;n>0;n--) { DrawEllipse(&rastport,10L,49L,n,n); }
  262. SetAPen(&rastport,1L);
  263. DrawEllipse(&rastport,10L,49L,9L,8L);
  264. plot(10,43); plot(10,44); plot(13,46); plot(16,48);
  265. SetAPen(&rastport,5L); plot(9,57); plot(10,56);
  266. plot(12,56); plot(14,55);  /* Akmuo */
  267.  
  268. for(n=0;n<9;n++)
  269.  {SetAPen(&rastport,n/2+2);
  270.   Move(&rastport,9-n,60+n);
  271.   Draw(&rastport,n+9,60+n);
  272.  }
  273. for(n=9;n>0;n--)
  274.  {SetAPen(&rastport,n/2+2);
  275.   Move(&rastport,9-n,79-n);
  276.   Draw(&rastport,n+9,79-n);   /* Kristalas */
  277.  }
  278.  
  279. SetAPen(&rastport,2L); RectFill(&rastport,1L,81L,20L,99L);
  280. SetAPen(&rastport,3L); RectFill(&rastport,4L,84L,15L,95L);
  281. SetAPen(&rastport,4L); RectFill(&rastport,7L,87L,12L,92L); /* Blake */
  282.  
  283.  
  284. SetAPen(&rastport,6L);
  285. RectFill(&rastport,0L,20L,20L,39L);
  286. SetAPen(&rastport,0L); Move(&rastport,7L,29L); Draw(&rastport,18L,27L);
  287. Move(&rastport,8L,23L); Draw(&rastport,20L,21L);
  288. plot(5,21); plot(13,22); SetAPen(&rastport,1L); plot(16,25);
  289. plot(19,27);                          /* Zeme */
  290.  
  291. SetAPen(&rastport,1L);
  292. RectFill(&rastport,0L,159L,20L,179L);
  293. SetAPen(&rastport,0L);
  294. Move(&rastport,0L,164L);
  295. Draw(&rastport,20L,164L);
  296. Move(&rastport,0L,169L);
  297. Draw(&rastport,20L,169L);
  298. Move(&rastport,0L,174L); Draw(&rastport,20L,174L);
  299. Move(&rastport,0L,178L); Draw(&rastport,20L,178L);
  300. Move(&rastport,3L,159L); Draw(&rastport,3L,164L);
  301. Move(&rastport,13L,159L); Draw(&rastport,13L,164L);
  302. Move(&rastport,8L,164L); Draw(&rastport,8L,169L);
  303. Move(&rastport,18L,164L); Draw(&rastport,18L,169L);
  304. Move(&rastport,3L,169L); Draw(&rastport,3L,174L);
  305. Move(&rastport,13L,169L); Draw(&rastport,13L,174L);
  306. Move(&rastport,8L,174L); Draw(&rastport,8L,178L);
  307. Move(&rastport,18L,174L); Draw(&rastport,18L,178L);   /* Muras */
  308.  
  309. SetAPen(&rastport,6L);
  310. RectFill(&rastport,1L,141L,20L,159L);
  311. spot(4,142); spot(4,152); spot(13,142); spot(13,152); /* metAlas */
  312.  
  313. SetAPen(&rastport,7L);
  314. RectFill(&rastport,0L,120L,20L,139L);
  315. SetAPen(&rastport,0L);
  316. RectFill(&rastport,3L,123L,7L,127L);
  317. RectFill(&rastport,13L,132L,16L,134L);
  318. /* Kvazi Magme */
  319. SetAPen(&rastport,1L); square(0,180,20,199);
  320. square(3,183,17,196);
  321. SetAPen(&rastport,7L); square(1,181,19,198);
  322. SetAPen(&rastport,3L); square(2,182,18,197);
  323.  
  324. SetAPen(&rastport,6L);
  325. RectFill(&rastport,3L,203L,14L,207L);
  326. Move(&rastport,6L,208L); Draw(&rastport,11L,208L);
  327. Move(&rastport,4L,202L); Draw(&rastport,5L,202L);
  328. Move(&rastport,12L,202L); Draw(&rastport,13L,202L);
  329. RectFill(&rastport,2L,205L,15L,206L);
  330. SetAPen(&rastport,1L); Move(&rastport,0L,213L); Draw(&rastport,1L,213L);
  331. Draw(&rastport,4L,210L); Draw(&rastport,14L,210L); Draw(&rastport,17L,213L);
  332. Draw(&rastport,18L,213L); RectFill(&rastport,5L,212L,13L,214L);
  333. RectFill(&rastport,4L,215L,5L,217L); RectFill(&rastport,13L,215L,14L,217L);
  334. Move(&rastport,2L,217L); Draw(&rastport,3L,217L); Move(&rastport,15L,217L);
  335. Draw(&rastport,16L,217L); plot(6,211); plot(21,211);
  336. SetAPen(&rastport,7L); Move(&rastport,6L,213L); Draw(&rastport,11L,213L);
  337. SetAPen(&rastport,0L); RectFill(&rastport,4L,205L,6L,206L);
  338. RectFill(&rastport,11L,205L,13L,206L); /* Rockford ® */
  339.  
  340. SetAPen(&rastport,1L); Move(&rastport,5L,225L); Draw(&rastport,15L,235L);
  341. Move(&rastport,7L,233L); Draw(&rastport,13L,225L);
  342. SetAPen(&rastport,7L); Move(&rastport,7L,226L); Draw(&rastport,13L,227L);
  343. Move(&rastport,5L,230L); Draw(&rastport,15L,229L);
  344. SetAPen(&rastport,1L); Move(&rastport,0L,221L); Draw(&rastport,20L,238L);
  345. Move(&rastport,20L,221L); Draw(&rastport,0,239L); plot(9,229); plot(10,230);
  346. plot(5,230); plot(15,235); Move(&rastport,9L,223L);
  347. Draw(&rastport,11L,239L); Draw(&rastport,8L,225L);
  348. Move(&rastport,0L,231L); Draw(&rastport,20L,229L);
  349. Draw(&rastport,4L,229L);
  350.  /* Blast ! */
  351. a=43; b=48;
  352. SetAPen(&rastport,5L); RectFill(&rastport,42L,0L,62L,250L);
  353. SetAPen(&rastport,1L); Move(&rastport,a,1L); Draw(&rastport,b,1L);
  354. Draw(&rastport,b,8L); Draw(&rastport,a,8L); Draw(&rastport,a,1L);
  355.  
  356. Move(&rastport,45L,11L); Draw(&rastport,45L,18L); plot(44,12);
  357.  
  358. Move(&rastport,a,21L); Draw(&rastport,b,21L);
  359. Draw(&rastport,b,24L); Draw(&rastport,a,24L);
  360. Draw(&rastport,a,28L); Draw(&rastport,b,28L);
  361.  
  362. Move(&rastport,a,31L); Draw(&rastport,b,31L);
  363. Draw(&rastport,b,38L); Draw(&rastport,a,38L);
  364. Move(&rastport,a,34L); Draw(&rastport,b,34L);
  365.  
  366. Move(&rastport,a,41L); Draw(&rastport,a,44L);
  367. Draw(&rastport,b,44L); Move(&rastport,b,41L);
  368. Draw(&rastport,b,48L);
  369.  
  370. Move(&rastport,b,51L); Draw(&rastport,a,51L);
  371. Draw(&rastport,a,54L); Draw(&rastport,b,54L);
  372. Draw(&rastport,b,58L); Draw(&rastport,a,58L);
  373.  
  374. Move(&rastport,b,61L); Draw(&rastport,a,61L);
  375. Draw(&rastport,a,68L); Draw(&rastport,b,68L);
  376. Draw(&rastport,b,64L); Draw(&rastport,a,64L);
  377.  
  378. Move(&rastport,a,71L); Draw(&rastport,b,71L);
  379. Draw(&rastport,b,78L);
  380.  
  381. Move(&rastport,a,81L); Draw(&rastport,b,81L);
  382. Draw(&rastport,b,88L); Draw(&rastport,a,88L);
  383. Draw(&rastport,a,81L); Move(&rastport,a,84L);
  384. Draw(&rastport,b,84L);
  385.  
  386. Move(&rastport,b,94L); Draw(&rastport,a,94L);
  387. Draw(&rastport,a,91L); Draw(&rastport,b,91L);
  388. Draw(&rastport,b,98L); Draw(&rastport,a,98L);
  389.  /* Tai buvo skaiciai nuo 0 iki 9 */
  390. Move(&rastport,a,101L); Draw(&rastport,a,108L); Draw(&rastport,b,108L);
  391. Move(&rastport,45L,111L); Draw(&rastport,45L,118L);
  392. Move(&rastport,a,121L); Draw(&rastport,45L,128L);
  393. Draw(&rastport,48L,121L);
  394. Move(&rastport,b,131L); Draw(&rastport,a,131L); Draw(&rastport,a,138L);
  395. Draw(&rastport,b,138L); Move(&rastport,a,134L); Draw(&rastport,b,134L);
  396. Move(&rastport,b,141L); Draw(&rastport,a,141L); Draw(&rastport,a,148L);
  397. Draw(&rastport,b,148L);
  398. Move(&rastport,a,158L); Draw(&rastport,a,151L); Draw(&rastport,b,151L);
  399. Draw(&rastport,b,154L); Draw(&rastport,a,154L); Draw(&rastport,b,158L);
  400. Move(&rastport,a,161L); Draw(&rastport,b,161L); Move(&rastport,45L,161L);
  401. Draw(&rastport,45L,168L);
  402. Move(&rastport,a,171L); Draw(&rastport,a,178L); Move(&rastport,b,171L);
  403. Draw(&rastport,b,178L); Move(&rastport,a,174L); Draw(&rastport,b,174L);
  404. Move(&rastport,a,184L); Draw(&rastport,b,184L);
  405.  
  406. } /* END of Makegraphics */
  407. square(x,y,x2,y2)
  408. LONG x,y,x2,y2;
  409. { Move(&rastport,x,y); Draw(&rastport,x2,y); Draw(&rastport,x2,y2);
  410. Draw(&rastport,x,y2); Draw(&rastport,x,y); }
  411. spot(x,y)
  412. LONG x,y;
  413. { SetAPen(&rastport,0L); RectFill(&rastport,x,y,x+4L,y+4L);
  414.   SetAPen(&rastport,5L); RectFill(&rastport,x-1L,y-1L,x+3,y+3);
  415. }
  416. plot(x,y)
  417. LONG x,y;
  418. { Move(&rastport,x,y); Draw(&rastport,x,y); }
  419. Tekstscreen(xx,yy)
  420. SHORT xx,yy;
  421. {
  422.   rasinfo.RxOffset = xx;
  423.   rasinfo.RyOffset = yy;
  424.   MakeVPort(&view,&viewport);
  425.   MrgCop(&view);
  426.   LoadView(&view);
  427. }
  428.  
  429. /* --------------------------------------------------------------*/
  430. FMemory()
  431. {
  432. LONG i;
  433. LoadView(oldview);
  434. WaitTOF(); Delay(1);
  435. for(i=0;i<DEPTH; i++) { if (bitmap.Planes[i] != NULL) {
  436.   FreeRaster(bitmap.Planes[i],WIDTH,HEIGHT);
  437.  }}
  438. if (cm != NULL) FreeColorMap(cm);
  439. FreeVPortCopLists(&viewport);
  440. FreeCprList(view.LOFCprList);
  441. CloseLibrary(GfxBase);
  442. return;
  443. }
  444.  
  445. SHORT galima(range)
  446. short range;
  447. {
  448. static int konst;
  449. short l=0;
  450. konst+=range;
  451. if(konst>254) {konst-=254; l=1; }
  452. return(l);
  453. }
  454.  
  455.